<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/6
 * Time: 20:55
 */


require_once "../config/config.php";
require_once "../model/adminDb.php";
$adminDb = new adminDb();
$id = $_POST['id'];
$addtime = time();
$name = $_SESSION['name'];
$userData = $adminDb->query_userName($name);

$card = $userData[0]['card'];



if ($card == "1") {

    $addData = $adminDb->del_user($id);
    try {

        if ($addData) {
            $dat = array(
                'msg' => "删除成功",
                "code" => 200,

            );
            echo json_encode($dat);
        } else {
            $dat = array(
                "code" => 404,
                'msg' => "删除失败",

            );
            echo json_encode($dat);

        }
    } catch (Exception $e) {

        // 回滚事务
        // $pdo->rollback();
        echo $e->getMessage();
    }


}
else {
    $dat = array(
        'msg' => "操作失败，需管理员的权限",
        "code" => 102,

    );
    echo json_encode($dat);


}










